package com.qcby.dao;

import com.qcby.entity.PersonalFavoritesFolder;
import com.qcby.entity.Shop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface PersonalCollectionDao {

    // 通过用户名查询用户的id
    int getUserIdByName(String username);

    // 通过用户id和所进入的文件夹查询用户的收藏夹
    List<PersonalFavoritesFolder> selectFavoritesList(@Param("u_id") Integer u_id,
                                                      @Param("fatherFolderId") Integer fatherFolderId);

    // 通过用户id和收藏夹id查询用户收藏的店铺
    List<Shop> selectFavoriteShop(@Param("u_id") Integer u_id,
                                  @Param("folderId") Integer folderId);

    // 新建收藏夹
    int createFolder(PersonalFavoritesFolder folderInfo);

    // 查询每个收藏夹下的收藏店铺数量
    int getFavoriteNumInFolder(int folder_id, int u_id);

    // 将查询出来的每个收藏夹下的收藏店铺数量进行更新
    int updateFavoriteNumInFolder(int folder_id,int shop_count);

    Integer collection(
            @Param("userId") Integer userId,
            @Param("shopId") Integer shopId,
            @Param("reason") String reason,
            @Param("folderId") Integer folderId
    );

    // 删除收藏店铺
    int deleteFavoriteShop(@Param("shopId") int shopId ,
                           @Param("Uid") int u_id,
                           @Param("folderId") int folderId);

    // 重新收藏回来店铺
    int recollectFavoriteShop(@Param("shopId") int shopId ,
                              @Param("Uid") int u_id,
                              @Param("folderId") int folderId);

    List<PersonalFavoritesFolder> findFolderByFatherId(@Param("userId") Integer userId,
                                                       @Param("fatherId") Integer fatherId);

    PersonalFavoritesFolder findFolderById(@Param("folderId") int folderId,
                                           @Param("userId") int userId);

    void updateShopCount(@Param("userId") int userId,
                         @Param("folderId") int folderId ,
                         @Param("shopCount") int totalShopCount);

    int findShopCountInFolderById(@Param("folderId") int folderId,@Param("userId") int userId);
}
